/**
 * consultDB 咨询列表
 */
const consultDB = uniCloud.database()
exports.main = async (event, context) => {
	let {
		page,
		pageSize,
		consultState
	} = event;

	if(consultState == 0){
		let consult = await consultDB.collection('consult_list')
			.skip((page - 1) * pageSize)
			.limit(pageSize)
			.get();
			if(consult != null){
				return {
					"page": page,
					"pageSize": pageSize,
					'errCode': 0,
					'errMsg': '获取咨询类表数据成功',
					'data': consult
				}
			} else {
				return {
					'errCode': 1,
					'errMsg': '出现错误',
					'data': consult
				}
			}
	}

	if(consultState == 1){
		let consult = await consultDB.collection('consult_list')
			.aggregate()
			.lookup({
			  from: 'specialDetails_list',
			  localField: 'auctionId',
			  foreignField: 'auctionId',
			  as: 'auctionList'
			})
			.end()
		return consult
	}

};
